{extend name="common/base" /}
{block name="body"}
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-header">修改个人资料</div>
                        <div class="layui-card-body">
                            <div class="layui-form" lwid100 iwid300 lay-filter="form">
                                <div class="layui-form-item">
                                    <label class="layui-form-label"></label>
                                    <div class="layui-input-inline">
                                        <div class="profile-avatar-div">
                                            <img class="profile-avatar-img layui-circle" id="profile_avatar_preview"
                                                 src="{:cmf_get_image_url($info['avatar']?:'/static/images/avatar.png')}">
                                        </div>
                                        <input name="avatar" id="profile_avatar_value"
                                               type="hidden" class="layui-input" value="{$info.avatar|default=''}">
                                        <a id="profile_avatar_upload">上传头像</a>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">用户名</label>
                                    <div class="layui-input-inline">
                                        <input type="text" readonly value="{$info.user_login}" autocomplete="off"
                                               class="layui-input">
                                    </div>
                                    <div class="layui-form-mid layui-word-aux pass-tips">不可编辑</div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">昵称</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="user_nickname" value="{$info.user_nickname}"
                                               autocomplete="off"
                                               class="layui-input">
                                    </div>
                                    <div class="layui-form-mid layui-word-aux pass-tips"></div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">性别</label>
                                    <div class="layui-input-inline">
                                        <input type="radio" name="sex" value="0" title="保密" {if $info.sex== 0}checked{/if}>
                                        <input type="radio" name="sex" value="1" title="男" {if $info.sex== 1}checked{/if}>
                                        <input type="radio" name="sex" value="2" title="女" {if $info.sex== 2}checked{/if}>
                                    </div>
                                    <div class="layui-form-mid layui-word-aux pass-tips"></div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">生日</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="birthday" value="{$info.birthday}" autocomplete="off"
                                               class="layui-input">
                                    </div>
                                    <div class="layui-form-mid layui-word-aux pass-tips"></div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">个人网站</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="user_url" value="{$info.user_url}" autocomplete="off"
                                               class="layui-input">
                                    </div>
                                    <div class="layui-form-mid layui-word-aux pass-tips"></div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">个性签名</label>
                                    <div class="layui-input-inline">
                                        <textarea class="layui-textarea" name="signature">{$info.signature}</textarea>
                                    </div>
                                    <div class="layui-form-mid layui-word-aux pass-tips"></div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-input-block">
                                        <button class="layui-btn" lay-submit lay-filter="form">保存</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="my_js"}
<script>
    layui.use(['element', 'admin', 'form', 'plupload', 'laydate'], function () {
        var element = layui.element
            , admin = layui.admin
            , $ = layui.$
            , plupload = layui.plupload
            , form = layui.form;
        var laydate = layui.laydate;
        laydate.render({
            elem: 'input[name="birthday"]' //指定元素
        });
        admin.imgUploadBtn(plupload, 'profile_avatar');
        form.on('submit(form)', function (data) {
            admin.ajax('admin/profile', data.field, function (data) {
                if (data.code == 1001) {
                    layer.msg(data.msg, function () {
                        location.reload();
                    });
                } else {
                    layer.msg(data.msg);
                }
            }, '', 'put');
        });
    });
</script>
{/block}